
package org.ethereum.net.dpos;

import org.ethereum.net.message.Message;

public abstract class EOrgMessage extends Message {

	public static enum ResponseCode {
		SUCCESS(1), 
		WIN(2), 
		LOOKING(3);
		// NOTICE: please DON'T set a number greater then 128, otherwise, the codec will not function!
		
		private final int code;
		private ResponseCode(int code) {
			this.code = code;
		} 
		
		public int getCode() {
			return code;
		}
		
		public static ResponseCode code(int code) {
			if (code == SUCCESS.code) {
				return SUCCESS;
			} else if (code == WIN.code) {
				return WIN;
			} else if (code == LOOKING.code) {
				return LOOKING;
			}
			throw new IllegalArgumentException("Unsupported code: " + code);
		}
	}
	
	protected ResponseCode responseCode = ResponseCode.SUCCESS;
	
    public EOrgMessage() {
    }

    public EOrgMessage(byte[] encoded) {
        super(encoded);
    }

    abstract public EOrgMessageCodes getCommand();
    
    public ResponseCode getResponseCode() {
    		return responseCode;
    }
    
//    public void setResponseCode(ResponseCode code) {
//    		this.responseCode = code;
//    }
}
